package com.carbon.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.carbon.domain.Ware;
import com.carbon.dto.WareDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * 仓库(Ware)表数据库访问层
 *
 * @author WangFK
 * @since 2023-08-21 13:19:47
 */
@Mapper
public interface WareMapper extends BaseMapper<Ware> {
    @Select("SELECT\n" +
            "\tt1.ware_name as warePositionDto,\n" +
            "\tt2.ware_name as wareAreaDto,\n" +
            "\tt3.ware_name as wareNameDto\n" +
            "FROM\n" +
            "\tware t1\n" +
            "\tLEFT JOIN ware t2 ON t2.id = t1.parend_id \n" +
            "\tLEFT JOIN ware t3 on t3.id=t2.parend_id\n" +
            "WHERE\n" +
            "\tt1.id =#{wareId}")
    public WareDto getWareNodeById(Integer wareId);
    @Select("SELECT\n" +
            "\tt1.id as warePositionDtoId,\n" +
            "\tt2.id as wareAreaDtoId,\n" +
            "\tt3.id as wareNameDtoId\n" +
            "FROM\n" +
            "\tware t1\n" +
            "\tLEFT JOIN ware t2 ON t2.id = t1.parend_id \n" +
            "\tLEFT JOIN ware t3 on t3.id=t2.parend_id\n" +
            "WHERE\n" +
            "\tt1.id =#{wareId}")
    WareDto getWareIdNodeById(Integer wareId);
}

